﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using www.serviciipeweb.ro.iafblog.ExportHierarchical;

namespace www.serviciipeweb.ro.iafblog.ExportHierarchicalImplementation
{

    /// <summary>
    /// exports file in directory
    /// </summary>
    public class DirInfo : ST_Node<DirectoryInfo>
    {
        public DirInfo(string PathDir, int level)
            : this(new DirectoryInfo(PathDir), level)
        {
        }
        public DirInfo(DirectoryInfo dir, int level)
            : base(dir, "Name", "FullName")
        {

            Level = level;


            this.AddProperty("Attributes");
            this.AddProperty("CreationTime");
            HashTableAddRecursiveObjects htFiles = this.AddObjects("GetFiles()", "Name", "FullName");

            htFiles.AddPropertyToValues("Name");
            htFiles.AddPropertyToValues("CreationTime");


            HashTableAddRecursiveObjects ht = new HashTableAddRecursiveObjects();

            //TODO : implement as maximum level
            if (level > 2)
                return;

            int NextLevel = this.Level + 1;
            foreach (DirectoryInfo di in dir.GetDirectories())
            {
                ht.Add(di.FullName, new DirInfo(di.FullName, NextLevel));
            }

            this.AddObject("Directories", ht);




        }
    }
    public class FInfo : ST_Node<FileInfo>
    {
        public FInfo(FileInfo fi)
            : base(fi)
        {

        }
    }
}